package com.blt.car.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.blt.car.R;
import com.blt.car.utils.Uiutils;

import blt.app_core.api.purse.bean.PurseVo;

/**
 * Created by xgp on 2017/6/28.
 */

public class BalanceDialog extends Dialog {
    private PurseVo purseVo;
    private Context context;

    public BalanceDialog(Context context, PurseVo purseVo) {
        super(context, R.style.CommonDialog);
        setCancelable(false);
        setCanceledOnTouchOutside(true);
        this.context = context;
        this.purseVo = purseVo;
    }

    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        window.setGravity(Gravity.CENTER);  //此处可以设置dialog显示的位置
//        window.setWindowAnimations(R.style.Dialog_Anim);  //添加动画
        WindowManager.LayoutParams params = window
                .getAttributes();
        params.width = Uiutils.dip2px(252);
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_balance);
        findViewById(R.id.dialog_balance_iv_cancle).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        findViewById(R.id.dialog_i_know).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        TextView voucher = (TextView) findViewById(R.id.dialog_balance_voucher);
        TextView send = (TextView) findViewById(R.id.dialog_balance_send);
        long balance = (purseVo.chargeAmt + purseVo.giveAmt) / 100;
        voucher.setText(context.getResources().getString(R.string.dialog_voucher, balance));
        send.setText(context.getResources().getString(R.string.dialog_send, purseVo.giveAmt / 100));

    }
}
